package com.wolf.server;

import com.wolf.coder.WolfDecoder;
import com.wolf.coder.WolfEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.FixedLengthFrameDecoder;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LineBasedFrameDecoder;

/**
 * @auth: dylan
 * @Desc:
 * @Time: 2024/4/30
 */
public class WolfChannelInitializer extends ChannelInitializer<NioSocketChannel> {
    @Override
    protected void initChannel(NioSocketChannel channel) throws Exception {
        channel.pipeline()
                //协议解码器
                .addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,5,4,0,0))
                 // 添加解码器
                .addLast(new WolfDecoder())
                //添加编码器
                .addLast(new WolfEncoder())
                .addLast(new ServerInboundHandler())
                 ;

    }
}
